<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>{{$t('dashBoard.no19')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('dashBoard.no12')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('dashBoard.no13')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <!-- -------------搜索查询栏------------------------ -->
    <search 
      :searchData="searchData" 
      @search="search" 
      :searchRight="true"
    ></search>
    <!-- :outputRight="$store.state.common.permiss.includes('RIGHT_ACCOUNT_LENDING_EXP')" -->

    <!-- -------------表格数据开始------------------------ -->
    <!-- <div class="table" v-if="$store.state.common.permiss.includes('RIGHT_ACCOUNT_LENDING_LIST')"> -->
    <div class="table">
      <el-table :data="tableData" stripe size="small" >
        <el-table-column align="center" prop="partnerNo" :label="$t('merchantList.no8')"></el-table-column>
        <el-table-column align="center" prop="partnerName" :label="$t('merchantList.no1')"></el-table-column>
        <el-table-column align="center" prop="payChannelList" :label="$t('add.no51')">
          <template slot-scope="scope" >
            <span>{{scope.row.payChannelList.join()}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="repayChannelList" :label="$t('auditManage.no8')">
          <template slot-scope="scope" >
            <span>{{scope.row.repayChannelList.join()}}</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" align="center" prop="operation" :label="$t('public.operation')" min-width="180">
          <template slot-scope="scope" >
            <!-- 渠道配置 -->
            <span v-if="$store.state.common.permiss.paychannellist.includes('channelconfig')" class="table_opr" @click="jumpDetail('paychannellistconfig',scope.row.partnerId)">{{$t('noteConfig.no3')}}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>

    <div class="foot"></div>

  </div>
</template>
<script>
export default {
  name: 'PayChannelList',
  data () {
    const searchData=[
      {
        type: 'input',
        label: 'merchantList.no8',
        attr: 'partnerNo',
        value: ''
      },
      {
        type: 'input',
        label: 'merchantList.no1',
        attr: 'partnerName',
        value: ''
      },{
        type: 'select',
        label: 'add.no51',
        attr: 'channelNameOne',
        option: [],
        value: '',
        langFlag: false,
      },{
        type: 'select',
        label: 'auditManage.no8',
        attr: 'channelNameTwo',
        option: [],
        value: '',
        langFlag: false,
      },
    ]
    return {
      loadFlag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      searchData:searchData,
      formInline: {},// 用户查询信息数据对应字段
      tableData: [],// 表格数据
      channelOptions1: [],
      channelOptions2: [],
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    search(search) { // 搜索
      this.formInline = {
        partnerNo: search.partnerNo,
        partnerName:search.partnerName,
        channelNameTwo: search.channelNameTwo,
        channelNameOne: search.channelNameOne,
      };
      this.pagination.current = 1;
      this.getTableData();
    },
    getTableData () { // 列表数据获取
      this.loadFlag = true;
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          ...this.formInline
        }       
      }
      this.$axios.post(this.$action.pay_config_list, option).then(res => {
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.pagination.total = res.data.total;
        }else{
          this.$globalMsg.error(res.message)
        }
        this.loadFlag = false;
      })
    },
    jumpDetail(path,id){
      this.$router.push({ path,query:{id} })
    },
    getChannelData(type){//获取借款放款渠道下拉框数据
      let option = {
        param:{
          channelType: type
        }
      }
      this.$axios.post(this.$action.channel_list, option).then(res => {
        if (res.code == 200) {
          let arr = res.data
          arr.forEach(item=>{
            if(type==3){this.channelOptions1.push({value:item.channelName,label:item.channelName})}
            if(type==4){this.channelOptions2.push({value:item.channelName,label:item.channelName})}
          })
          this.searchData.filter(value=>value.attr=='channelNameOne')[0].option = this.channelOptions1
          this.searchData.filter(value=>value.attr=='channelNameTwo')[0].option = this.channelOptions2
				}
      })
    },
  },
  mounted () {
    this.getTableData();
    this.getChannelData(3);
    this.getChannelData(4);
    
  }
}
</script>
<style scoped lang="scss">

</style>
